﻿/*
using Cysharp.Threading.Tasks;
using Newtonsoft.Json;
using System;
using System.Text;
using UnityEngine.Networking;
using YooAsset;

namespace Client.Base
{
    public class FsmNetConfig : PatchState
    {
        public override void OnEnter()
        {
            this.Log("[补丁] 请求补丁配置.");
            RequestNetConfig(
            json =>
            {
                PatchHandle.Instance.SetNetConfig(json);
                PatchHandle.Instance.Change<FsmInitPackage>();
            },
            error =>
            {
                PatchHandle.Instance.OnError(PatchErrorCode.PatchError_GetNetConfigFailed);
            });
        }

        private void RequestNetConfig(Action<string> onSuccess, Action<string> onFailed)
        {
            //拉取更新配置
            string url = PatchHandle.Instance.NetConfigUrl;
            Request(url, onSuccess, onFailed);
        }


        private async void Request(string url, Action<string> onSuccess, Action<string> onFailed)
        {
            using (UnityWebRequest request = new UnityWebRequest(url, "POST"))
            {
                HotFixRequest req = new HotFixRequest
                {
                    channel = AppInfo.ChannelID,
                    platform = AppInfo.PlatformID
                };
                byte[] buffer = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(req));
                request.uploadHandler=  new UploadHandlerRaw(buffer);
                request.downloadHandler = new DownloadHandlerBuffer();
                request.SetRequestHeader("Content-Type", "application/json");
                await request.SendWebRequest().ToUniTask();
                if (request.result != UnityWebRequest.Result.Success)
                {
                    this.Log($"[补丁失败]: 获取更新地址失败 ！-> {request.error}");
                    onFailed?.Invoke(request.error);
                }
                else
                {
                    string content = request.downloadHandler.text;
                    this.Log($"respone -> {url} \n\n {content}");
                    onSuccess?.Invoke(content);
                }
            }
        }
    }

}
*/